<template>
  <div class="main">
    <div class="title"></div>
    <div class="sub_main">
      <div class="content">
        {{ msg }}
      </div>

      <van-button type="primary" round class="btn" @click="goBack"
        >返回</van-button
      >
    </div>
  </div>
</template>
<script>
import Vue from "vue";
import { Button } from "vant";
import { mapState, mapGetters } from "vuex";
import { getAuthen } from "@/utils/getAuthen";
Vue.use(Button);

export default {
  data() {
    return {
      msg: "",
      tempEnterpriseId: "",
      ruleId: "",
    };
  },
  created() {
    if (!this.userInfo.mobilePhone || !this.userInfo.userId) {
      getAuthen();
      return false;
    }
    this.tempEnterpriseId =
      this.$route.query.enterpriseId || sessionStorage.getItem("enterpriseId");
    this.ruleId = this.$route.query.ruleId;
    this.$axios
      .$post("/electronic/deputy/add", {
        ruleId: this.ruleId,
        userId: this.userInfo.userId,
      })
      .then((res) => {
        this.msg = res.message;
      });
  },
  computed: {
    ...mapGetters({
      userInfo: "authen/userInfo",
    }),
  },
  methods: {
    goBack() {
      location.href =
        window.location.origin +
        `/${this.tempEnterpriseId}/subCard?userId=${this.userInfo.userId}`
      // this.$router.push({
      //   path: `/${this.tempEnterpriseId}/subCard`,
      // });
    },
  },
};
</script>
<style lang="scss" scoped>
.main {
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.04);
  padding: 0.3rem;
  box-sizing: border-box;
  font-size: 0.3rem;
  .title {
    font-size: 0.4rem;
    text-align: center;
    font-weight: 500;
    height: 1rem;
    line-height: 1rem;
  }
  .sub_main {
    height: 50vh;
    background-color: #fff;
    border-radius: 0.2rem;
    display: flex;
    flex-direction: column;
    padding: 1rem 0.5rem;
    position: relative;
    .content {
      height: 30vh;
      padding: 1.5rem 0.5rem;
      display: flex;
      align-items: center;
      box-sizing: border-box;
      flex-direction: column;
      div {
        line-height: 0.8rem;
      }
    }
    .btn {
      position: absolute;
      bottom: 0.5rem;
      width: 6rem;
    }
  }
}
</style>
